package round86;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

/**
 * User: Samuel
 * Date: 09-08-11
 * Time: 09:36 AM
 */
public class BB {
    public static void main(String[] args) throws IOException {
        new BB().run();
    }

    private void run() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String split[] = in.readLine().split(" ");
        int n = Integer.parseInt(split[0]);
        int m = Integer.parseInt(split[1]);
        Set<String> set = new HashSet<String>();
        List<String> names = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            names.add(in.readLine());
        }
        Map<String, List<String>> map = new HashMap<String, List<String>>();

        Map<String, PairC> pairCount = new HashMap<String, PairC>();
        for (int i = 0; i < m; i++) {
            split = in.readLine().split(" ");
            Pair p = new Pair(split[0], split[1]);
            if (set.add(p.a)) {
                pairCount.put(p.a, new PairC(p.a, 1));
                List<String> l = new ArrayList<String>();
                l.add(p.b);
                map.put(p.a, l);
            } else {
                pairCount.get(p.a).c++;
                map.get(p.a).add(p.b);
            }

            if (set.add(p.b)) {
                pairCount.put(p.b, new PairC(p.b, 1));
                List<String> l = new ArrayList<String>();
                l.add(p.a);
                map.put(p.b, l);
            } else {
                pairCount.get(p.b).c++;
                map.get(p.b).add(p.a);
            }
        }

        List<PairC> list = new ArrayList<PairC>(pairCount.values());
        Collections.sort(list);
        Set<String> notChoose = new HashSet<String>();
        set.clear();
        for (int i = 0; i < list.size(); i++) {
            PairC pc = list.get(i);
            if (notChoose.contains(pc.n)) {
                continue;
            }
            set.add(pc.n);
            for (String v: map.get(pc.n)) {
                notChoose.add(v);
            }
        }
        
        int k = n - notChoose.size();
        System.out.println(k);
        Collections.sort(names);
        for (int i = 0; i < n; i++) {
            if(notChoose.contains(names.get(i)))
                continue;
            System.out.println(names.get(i));
        }
    }
}

class Pair {
    String a, b;

    Pair() {

    }

    Pair(String x, String y) {
        a = x.compareTo(y) < 0 ? x : y;
        b = getOther(a);

    }

    String getOther(String x) {
        if (a.equals(x)) return b;
        else return a;
    }

}

class PairC implements Comparable<PairC> {
    String n;
    int c;

    PairC(String a, int x) {
        n = a;
        c = x;
    }

    public int compareTo(PairC o) {
        return c - o.c;
    }
}